package cn.utils.excelutil;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
/**
 @author zch */
public class LogUtil{
    public static String T = "	";
    public static String S = " ";
    public static String logLocation = "/resources/log/";
    public static String logpath_posRS = "receivesend/";
    public static String logpath_sysErrs = "exception/";
    public static String logpath_wx = "wx/";
    public static String logpath_phonemsg = "phonemsg/";
    public static String logpath_delLogFiles = "delFiles/";
    private static Map<Integer, Integer> map = new HashMap<>();
    /**
     获取年月日时分秒等
     */
    public static Integer getT(int t){
        Calendar calendar = Calendar.getInstance();
        // 年
        map.put(0,calendar.get(Calendar.YEAR));
        // 月
        map.put(1,calendar.get(Calendar.MONTH) + 1);
        // 日
        map.put(2,calendar.get(Calendar.DAY_OF_MONTH));
        // 时
        map.put(3,calendar.get(Calendar.HOUR_OF_DAY));
        // 分
        map.put(4,calendar.get(Calendar.MINUTE));
        // 秒
        map.put(5,calendar.get(Calendar.SECOND));
        // 周几  0~6
        map.put(6,calendar.get(Calendar.DAY_OF_WEEK));
        // 本年第N天
        map.put(7,calendar.get(Calendar.DAY_OF_YEAR));
        // 本月第N天
        map.put(8,calendar.get(Calendar.DAY_OF_MONTH));
        int i = -1;
        if(map.containsKey(t)){
            i = map.get(t);
        }
        return i;
    }
    /**
     byte 转换为 十六进制string
     */
    public static String bytes2HexString(byte[] b){
        String ret = "";
        for(int i = 0;i < b.length;i++){
            String hex = Integer.toHexString(b[i] & 0xFF);
            if(hex.length() == 1){
                hex = '0' + hex;
            }
            ret += hex.toUpperCase();
        }
        return ret;
    }
    /**
     组合路径之年月日
     */
    public static String getPathWithTime(String path){
        return path + getT(0) + "年/" + getT(1) + "月/" + getT(2) + "日/";
    }
    /**
     组合路径之年月
     */
    public static String getPathWithTimeToMonth(String path){
        return path + getT(0) + "年/" + getT(1) + "月/";
    }
    /**
     组合路径之年月
     */
    public static String getPathWithTimeToYear(String path){
        return path + getT(0) + "年/";
    }
}
